package com.gqyin.cloud.ai.demo.service.impl;

import com.gqyin.cloud.ai.demo.service.TongYiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.image.ImageClient;
import org.springframework.ai.image.ImagePrompt;
import org.springframework.ai.image.ImageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author guiqing.yin
 * @Date 2024-05-14 16:46
 */
@Service
public class TongYiImagesServiceImpl extends AbstractTongYiServiceImpl {

    private static final Logger LOGGER = LoggerFactory.getLogger(TongYiService.class);

    private final ImageClient imageClient;

    @Autowired
    public TongYiImagesServiceImpl(ImageClient imageClient) {
        this.imageClient = imageClient;
    }

    @Override
    public ImageResponse genImage(String imagePrompt) {
        ImagePrompt prompt = new ImagePrompt(imagePrompt);
        return imageClient.call(prompt);
    }
}
